<!DOCTYPE html>
<html>
<head>
	<title></title>
	<!--[if lt IE 9]>
	<meta http-equiv="refresh" content="0;ie.html" />
	<![endif]-->

	<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico"> <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/channel.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
	<script src="__STATIC__/layout/js/jquery.min.js"></script>
	<!-- Sweet Alert -->
	<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<!-- Sweet alert -->
	<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
	<!-- layer javascript -->
	<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
 <style type="text/css">
 	
 	    .checkbox-inline input[type=checkbox],.radio-inline input[type=radio] {
    margin-top: 4px;
}
 </style>
</head>
<body class="white-bg">

<div class="ibox" style="padding:10px">
			<div class="ibox-content">
				<form role="form" id="formadd" method="post" action="{:url('update')}">
				<input type="hidden" name="id" value="{$data.id}">
				<div class="row form-group">
					<label class="col-sm-3 control-label">三级科目名称</label>
					<div class="col-sm-9">
						<input name="title" type="text" placeholder="三级科目名称" class="form-control" value="{$data.title}">
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">三级科目编号</label>
					<div class="col-sm-9">
						<input name="sn" type="text" placeholder="三级科目编号" class="form-control" value="{$data.sn}">
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">所属二级科目名称</label>
					<div class="col-sm-9">
						<select name="pid" id="pid" class='form-control'>
							<option value="">请选择</option>
							{volist name="yiji" id="row"}
							<option value="{$row.id}" {if $row.id==$data.pid}selected{/if}>{$row.title}</option>
							{/volist}
						</select>
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">费用科目类型：</label>
					<div class="col-sm-9">
						{volist name="feitype" id="vo"}
						<label for="radio-inline">
							<input type="radio" name="freekmlx" value="{$vo.id}" {if $vo.id==$data.freekmlx}checked{/if}> {$vo.title}
						</label>
						{/volist}
						
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">费用科目使用途径：</label>
					<div class="col-sm-9">
						{volist name="esuseway" id="row"}
						<label class="checkbox-inline">
							<input type="checkbox" name="esuseway[]" value="{$row.id}" class="check" data-id="sub{$row.id}" {if in_array($row.id,$data.esuseway)}checked{/if} >{$row.title}
						</label>
						{/volist}

					</div>
				</div>

				{volist name="esuseway" id="row"}
					{if isset($row._child)}
					<div class="row form-group" id="sub{$row.id}" {if in_array($row.id,$data.esuseway)}style="display:block;"{else}style="display:none;"{/if}>
						<label class="col-sm-3 control-label">{$row.title}类型</label>
							<div class="col-sm-9">
							{volist name="row._child" id="row2" key="k"}
							<label class="checkbox-inline">
								<input type="radio" name="tejiabuchatype" value="{$row2.id}" {if in_array($row.id,$data.esuseway)}{if $data.tejiabuchatype==$row2.id}checked{else}{/if}{else}{if $k==1}checked{else}{/if}{/if} >{$row2.title}</label>
							{/volist}
							</div>
					</div>
					{/if}
				{/volist}
				<div class="row form-group">
					<label class="col-sm-3 control-label">对应财务费用科目</label>
					<div class="col-sm-9">
						<select name="fifeiyongkemu" id="fifeiyongkemu" class='form-control'>
							<option value="">请选择</option>
							{volist name="fifeiyongkemu" id="row"}
							<option value="{$row.id}" {if $row.id==$data.fifeiyongkemu}selected{/if}>{$row.title}</option>
							{/volist}
						</select>
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">费用科目对应渠道类型：</label>
						<div class="col-sm-9">
							{volist name="channel_types1" id="row"}
							<label class="checkbox-inline">
							<input type="checkbox" name="channeltypes[]" value="{$row.id}" {if in_array($row.id,$data.channeltypes)}checked{/if} >{$row.title}</label>
							{/volist}
						</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">陈列选择</label>
					<div class="col-sm-9">
						<label for="radio-inline">
							<input type="radio" name="chenlie" value="0" {if !$data.chenlie}checked{/if}> 不适用
						</label>
						<label for="radio-inline">
							<input type="radio" name="chenlie" value="1" {if $data.chenlie}checked{/if}> 可选择陈列位置类型尺寸
						</label>
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">对应支付方式</label>
					<div class="col-sm-9">
					{volist name="pay" id="vo"}
						<label for="checkbox-inline">
							<input type="checkbox" name="payway[]" value="{$vo.id}" class="check" {if $data.payway}{if in_array($vo.id,$data.payway)}checked{/if}{/if}> {$vo.title}
						</label>
					{/volist}
						
						<span class="colorRed">（注：如未设定则默认支持所有支付方式）</span>
					</div>
				</div>
				<div class="row form-group">
					<label class="col-sm-3 control-label">描述</label>
					<div class="col-sm-9">
						<textarea name="brief" class="form-control" id="" cols="20" rows="5">{$data.brief}</textarea>
					</div>
				</div>
				<div style="padding: 20px 0;text-align: center;">
					<input class="btn btn-sm btn-primary" type="submit" id="tijiao" value="提 交">
				</div>
			</form>
		</div>

</div>

</body>
</html>
<script>
    $(function () {
        $('body').on('click','.check',function () {
            var id = $(this).data('id')
            if($(this).is(':checked')){
                $('#'+id).show()
            }else{
                $('#'+id).hide()
            }
        })

		//
        $('body').on('click','#tijiao',function () {
            var form =  $('#formadd')
            var data = form.serialize()
            $.ajax({
                'type':'post',
                'url':form.attr('action'),
                'data':data,
                'dataType':'json',
                'success':function (data) {
                    if(data.success){
                        swal({
                            title: data.msg,
                            type: "success"
                        },function(){
                            parent.location.reload()
						});

                    }else
                        swal({
                            title: data.msg,
                            type: "warning"
                        });
                }
            })
			return false
        })



    })
</script>